@push('title')
    <title>查询是否可退</title>
@endpush
@push('style2')
    <style>
        .layui-form-label {

            width: 80px;
        }
        .layui-form-item .layui-inline-padding {
            width: 78px; padding-right: 4px;
        }
        legend {
            color: #01AAED;
        }
    </style>
@endpush
@extends('layout.layer')
@section('content')
    <form class="layui-form layui-form-pane1" action="#" lay-filter="first">
        <input type="hidden" name="_token" value="{{csrf_token()}}">
        <div class="layui-form-item">
            <label class="layui-form-label">订单号</label>
            <div class="layui-input-inline">
                <input type="text" name="orderId" lay-verify="" value="" lay-reqText="订单号" required placeholder="订单号" autocomplete="off" class="layui-input" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">机票ID</label>
            <div class="layui-input-inline" style="width: 700px">
                <input type="text" name="ticketIds" lay-verify="" value=""  lay-reqText="机票ID" required placeholder="机票ID" autocomplete="off" class="layui-input" >
            </div>
            <div class="layui-form-mid">多个用,(英文,)分割</div>
        </div>

        <div class="layui-form-item" pane>
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <div class="layui-form-item" style="display: none" id="error-result">
        <label class="layui-form-label" >查询结果</label>
        <div class="layui-input-block">
            <label class="layui-form-label" style="width: 400px;text-align: left" ><span id="check-error-result" style="color: red"></span></label>
        </div>
    </div>
    <div class="layui-form-item"  style="display: none" id="result">
        <label class="layui-form-label">查询结果</label>
        <div class="layui-input-block">
            <table class="layui-table" style="width: 400px" id="check-result"></table>
        </div>

    </div>
@endsection
@push('script')
    <script src="/static/xml-select/xm-select.js"></script>
    <script>
        layui.use(['form','layer'], function() {

            var $ = layui.$
                ,form = layui.form
                ,layer = layui.layer;

            //监听提交
            form.on('submit(*)', function(data){

                $.ajax({
                    url: '/refund/ajaxCanRefund'
                    , method: 'post'
                    , data: data.field
                    , dataType: 'json'
                    , success: function (data) {


                        if(data.code != 1) {
                            $('#error-result').show();
                            $('#result').hide();
                            $('#check-error-result').html(data.msg);
                        } else {
                            $('#error-result').hide();
                            $('#result').show();
                            var resultStr = '';
                            $.each(data.data.ticketInfos,function (index,item) {

                                resultStr += '<tr><td>'+ item.ticketId+'</td><td>'


                                switch (item.canRefundStatus) {

                                    case -2: resultStr += '您的客票状态异常，请联系客服核实后提交退票';break
                                    case -1: resultStr += '不可退';break
                                    case 0: resultStr += '自愿可退';break
                                    case 1: resultStr += '非自愿可退';break
                                }
                                resultStr += '</td</tr>';

                            })
                            $('#check-result').html(resultStr);
                        }
                    },
                });

                return false;
            });



        });
    </script>
@endpush
